<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/sks/cms/page/share/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<% String path = request.getContextPath(); 
   String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> 用户信息</title>
<link rel="stylesheet" type="text/css" media="screen" href="<%=basePath %>sks/css/frontpages/common.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=basePath %>sks/css/frontpages/indexNew.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=basePath %>sks/css/frontpages/registe.css" />
<script type="text/javascript" src="<%=basePath %>sks/js/frontpages/select2css.js"></script>
<SCRIPT language=JavaScript src="/js/xmlhttp.js"></SCRIPT>
<script type="text/javascript" src="/js/jquery-1.3.1.min.js"></script>
  <SCRIPT LANGUAGE="JavaScript">
  
	function checkForm(){
		var form = document.forms[1];
		
		var familyNameWarn = document.getElementById("familyNameWarn");
		if(form.familyName.value=="" ){
			familyNameWarn.innerHTML = "请输入贵姓！";
			return false;
		}
		
		var checkResult = document.getElementById("checkResult");
		if(form.loginName.value=="" || form.loginName.value.length<5){
			checkResult.innerHTML = "请输入长度5位以上的账号！";
			return false;
		}
		
		var passwordWarn = document.getElementById("passwordWarn");
		if(form.loginPwd.value=="" || form.loginPwd.value.length<6){
			passwordWarn.innerHTML = "请输入长度6位以上的密码！";
			return false;
		}
		var repasswordWarn = document.getElementById("repasswordWarn");
		if(form.loginPwd.value!=form.repassword.value){
			repasswordWarn.innerHTML = "两次输入的密码不正确！";
			return false;
		}
		
		var cardNoWarn = document.getElementById("cardNoWarn");
		if(form.cardNo.value.length !="" && (form.cardNo.value.length != 15 && form.cardNo.value.length != 18 )){
			cardNoWarn.innerHTML = "请输入十八位身份证号码或者十五位身份证号码！";
			return false;
		}

		var emailWarn = document.getElementById("emailWarn");
		if(form.email.value==""){
		    emailWarn.innerHTML = "请输入邮箱地址！";
			form.email.focus();
			return false;
		}
		
		checkResult = document.getElementById("checkResult");
		if(/[\W]/g.test(form.loginName.value)){
			checkResult.innerHTML = "用户名中不能含有中文！";
			return false;
		}
		return true;
	}
	function checkFamilyName(){
		var reg = /^[\u4E00-\u9FFF]{1,2}$/;
		var pattern= /^[A-Za-z]+$/; 
		var value = $('#familyNameField').val();
		if(value!=""){
			if(!(pattern.test(value) || reg.test(value))){
				$('#familyNameWarn').text("姓氏只允许纯中文姓氏或者纯英文姓氏");
			}else{
				$('#familyNameWarn').text("");
				return true;
			}
		}
		return false;
	}
	function checkEmail(){
		var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/;
		var value = $('#emailField').val();
		if(value!=""){
			if(!reg.test(value)){
					$('#emailWarn').text("邮箱格式不正确");
			    }else{
			    	$('#emailWarn').text("");
			    	return true;
			    }
		}
		return false;
	   
	}
	function checkIdCard(){
		var reg_15 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
		var reg_18 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/; 
		var value = $('#cardNoField').val();
		if(value!=""){
			var isValid = false;
			if(value.length<18){
				isValid = !reg_15.test(value) ? false:true;
				
			}else if(value.length==18){
				isValid = !reg_18.test(value) ? false:true;
			}
			if(!isValid){
				$('#cardNoWarn').text("证件号码格式不正确");
			}else{
				$('#cardNoWarn').text("");
				return true;
			}
		}
		return false;
 
	}
	function checkMobileNo(){
		var reg = /^((13[0-9])|(15[^4,\D])|(18[0,5-9]))\d{8}$/;
		var value = $('#mobileField').val();
		if(value!=""){
			if(!reg.test(value)){
				$('#mobileWarn').text("联系电话号码格式不正确");
			}else{
				$('#mobileWarn').text("");
				return true;
			}
		}
		return false;
		
	}

	
	function checkLoginName(){
		var form = document.forms[1];
		var checkResult = document.getElementById("checkResult");
		if(form.loginName.value=="" || form.loginName.value.length<5){
			if ( form.loginName.value=="" ) {
				checkResult.innerHTML = "请输入账号！";					
			} else if ( form.loginName.value.length<5 ) {
				checkResult.innerHTML = "请输入长度5位以上的账号！";
			}
			return false;
		}
		var loginName = form.loginName.value;
		var viewobj = document.getElementById("checkResult");
		viewobj.innerHTML = "正在检测中...";
		send_request(function(value){viewobj.innerHTML=value;},
		'<html:rewrite action="/sks/privilege/user/reg.do"/>?method=isUserExsit&loginName='+ loginName, true);
	}
  
  </SCRIPT>
</head>

<body>

<div class="wrap" height="100%">
	<jsp:include page="../header.jsp"></jsp:include>
	<div>
		<div>
			<a href="<%=basePath%>" hidefocus="true">SKS房地产</a> &gt;
			<a href="<%=basePath%>sks/privilege/user/reg.do?method=regUI" target="_self" hidefocus="true">用户注册</a>					
		</div>		
		<div class="clear"></div>
	</div>
	<div class="content-wrap" >													
		<div class="usersReg">
		<html:form action="/sks/privilege/user/reg.do"  target="_self" method="post" >
			<input type="hidden" name="method" value="reg" />
			<%-- <input type="hidden" name="directUrl" value="${param.directUrl}" /> --%>
			<div class="bigbox">				
				<div class="colR">
					<div id="familyName" class="padding-left">
						<label ><span style="color:red">*</span>贵姓： </label>
						<input name="familyName" id="familyNameField" type="text" size="24" value="" tabindex="1"  maxlength="20" onblur="checkFamilyName()"/> 
						<label ></label><div id="familyNameWarn" style="margin:5px 10px 5px 0;float: left; color: red"></div><div style="clear: left;"></div>
					</div>
				</div>
				<div class="colR">
					<div id="loginName" class="padding-left">
						<label><span style="color:red">*</span>账号： </label>
						<input name="loginName" type="text" size="24" value="" tabindex="2"  maxlength="20" onkeyup="value=value.replace(/[\W]/g,'')" onblur="checkLoginName();" />
						<label ></label><div id="checkResult" style="margin:5px 10px 5px 0;float: left; color: red"></div><div style="clear: left;"></div>
						<!-- <label ></label>5-20个字符(包括小写字母、数字、下划线)
						<button name="check_loginName" value="检查账号是否可用" onClick="checkLoginName();return false;/*这里return false是为了暂时解决点击按钮表单不提交的问题*/" onMouseOver="this.style.cursor='hand'">检查账号是否可用</button>	 -->				
			        </div>
				</div>
				<div class="colR">
					<div id="loginPwd" class="padding-left">
						<label><span style="color:red">*</span>密码： </label>
						<input name="loginPwd" type="password" size="24" value="" tabindex="3"  maxlength="20" /> 
						<label ></label><div id="passwordWarn" style="margin:5px 10px 5px 0;float: left; color: red"></div><div style="clear: left;"></div>
					</div>
				</div>
				<div class="colR">
					<div id="repassword" class="padding-left">
						<label><span style="color:red">*</span>重复密码： </label>
						<input name="repassword" value="" id="repassword" type="password" size="24" maxlength="20" tabindex="4"/> 
						<label ></label><div id="repasswordWarn" style="margin:5px 10px 5px 0;float: left; color: red"></div><div style="clear: left;"></div>
					</div>
				</div>
				
				<div class="colR">
					<div id="sex" class="padding-left">
						<label><span style="color:red">*</span>性别： </label>
						<input type="radio" id="sexMale" name="sex" value = "MAN" style="width:auto; float: left;" checked="checked" tabindex="5"/><label for="sexMale" class="forRadio">男</label>
      					<input type="radio" id="sexFeMale" name="sex" value = "WOMEN" style="width:auto; float: left; margin-left: 20px;" tabindex="6"/><label for="sexFeMale" class="forRadio">女</label>
      					<label ></label><div id="sexWarn" style="margin:5px 10px 5px 0;float: left; color: red"></div><div style="clear: left;"></div>
					</div>
				</div>
				<div class="colR">
					<div id="cardNo" class="padding-left">
						<label>证件号码： </label>
						<input name="cardNo" id="cardNoField" type="text" size="20" value="" tabindex="7"  maxlength="18" onblur="checkIdCard()"/>
						<label ></label><div id="cardNoWarn" style="margin:5px 10px 5px 0;float: left; color: red"></div><div style="clear: left;"></div>
					</div>
				</div>
				<div class="colR">
					<div id="mobile" class="padding-left">
						<label>联系电话： </label>
						<input name="mobile" id="mobileField"type="text" size="20" value="" tabindex="8"  maxlength="20" onblur="checkMobileNo()"/>
						<label ></label><div id="mobileWarn" style="margin:5px 10px 5px 0;float: left; color: red"></div><div style="clear: left;"></div>
					</div>
				</div>
				<div class="colR">
					<div id="email" class="padding-left">
						<label><span style="color:red">*</span>邮箱：</label>
						<input name="email" id="emailField" type="text" size="20" value="" tabindex="9"  maxlength="20" onblur="checkEmail()"/>
						<label ></label><div id="emailWarn" style="margin:5px 10px 5px 0;float: left; color: red"></div><div style="clear: left;"></div>
					</div>
				</div>
				<!-- <div class="colR">
					<div id="address" class="padding-left">
						<label>家庭地址： </label>
						<input name="address" type="text" size="20" value="" tabindex="1"  maxLength="20" />
					</div>
				</div> -->
				<div class="colR">
					<div id="sumintR" class="padding-left">
						<!-- <input type="submit" name="Submit" value="提交注册信息" tabindex="8" /> -->
						<label ></label>
						<button type="submit" onclick="return checkForm()" tabindex="10">提交注册信息</button>
					</div>
				</div>
				<div class="colR">
					<div id="aaa1" class="padding-left">
						<label> </label>
					</div>
					<br />
				</div>
				<div class="colR">
					<div id="aaa2" class="padding-left">
						<label> </label>
					</div>
					<br />
				</div>
				<div class="colR">
					<div id="aaa2" class="padding-left">
						<label> </label>
					</div>
					<br />
				</div>
				<div class="colR">
					<div id="aaa2" class="padding-left">
						<label> </label>
					</div>
					<br />
				</div>
			</div>
		</html:form>
		</div>
	</div>
	<jsp:include page="../rooster.jsp"></jsp:include><%--尾部--%> 
</div>




</html>